﻿using System;

namespace _9.FiveIntegersAndSumOfSubsetIs0
{
    class FiveIntegersAndSumOfSubsetIs0
    {
        static void Main(string[] args)
        {
            //We are given 5 integer numbers. Write a program that checks if the sum of some subset of them is 0. Example: 3, -2, 1, 1, 8  1+1-2=0.
			long count = 0;
			
            long[] numbers;
			long sum = long.Parse(Console.ReadLine());
			long n = long.Parse(Console.ReadLine());
			if(n>0 && n<=16)
			{
				numbers = new long[n];
				//Input n variables
				for (long i = 0; i < numbers.Length; i++)
				{
					//Console.Write((i+1)+".");
					numbers[i] = long.Parse(Console.ReadLine());
					//Console.WriteLine();
				}
				//Console.WriteLine();
				//Print array of variables
				/*for (int i = 0; i < numbers.Length; i++)
				{
					Console.WriteLine((i+1)+"="+numbers[i]);
					
				}/*/
				//Print if one integer == sum
				if(numbers.Length>0 || numbers.Length==1) // if index out of range
				{
					for(long i = 0; i < numbers.Length; i++)
					{
						if(numbers[i]==sum)
						{
							//Console.WriteLine("{0}={1}", numbers[i],sum);
							count++;
						}
					}
				}
				//Console.WriteLine();
				//Print sum of two integers == sum
				if(numbers.Length>1 || numbers.Length==2) // if index out of range
				{
					for (long i = 0; i < numbers.Length; i++)
					{
						for (long j = 1; j < numbers.Length-1; j++)
						{
							if ((numbers[i] + numbers[j]) == sum)
							{
								//Console.WriteLine("{0}+{1}={2}", numbers[i], numbers[j],sum);
								count++;
							}
							
						}
					}
					//Console.WriteLine("\nOther Sum of two integers == 0 - NO!");
				}
				
				//Print sum of three integers == sum
				if(numbers.Length>2 || numbers.Length==3) // if index out of range
				{
					for (long i = 0; i < numbers.Length; i++)
					{
						for (long j = 1; j < numbers.Length - 2; j++)
						{
							if ((numbers[i] + numbers[j] + numbers[j+1]) == sum)
							{
								//Console.WriteLine("{0}+{1}+{2}={3}", numbers[i], numbers[j], numbers[j+1],sum);
								count++;
							}

						}
					}
					
					//Console.WriteLine("\nOther Sum of three integers == 0 - NO!");
				}
				
				//Print sum of four integers == sum
				/*if(numbers.Length>3 || numbers.Length==4) // if index out of range
				{
					for (int i = 0; i < numbers.Length; i++)
					{
						for (int j = 1; j < numbers.Length - 2; j++)
						{
							if ((numbers[i] + numbers[j] + numbers[j + 1] +numbers[j+2]) == sum)
							{
								//Console.WriteLine("\n{0}+{1}+{2}+{3}={4}", numbers[i], numbers[j], numbers[j + 1], numbers[j+2],sum);
								count++;
							}

						}
					}
					//Console.WriteLine("\nOther Sum of four integers == 0 - NO!");
				}/*/
				}/*/
				/*if(numbers.Length>4 || numbers.Length==5) // if index out of range
				{
					if ((numbers[0] + numbers[1] + numbers[2] + numbers[3] + numbers[4]) == sum)
					{
						//Console.WriteLine("\nSum of the first five numbers is : 0");
						count++;
					}
				}/*/
			//Console.WriteLine("Sum: {0}",sum);
			//Console.WriteLine("Count: {0}",count);
			Console.WriteLine(count);
			}	
		}
    }
//}

